package com.freewater.parking.infrastructure.db;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.time.LocalDateTime;

public interface ParkingViewDao extends JpaRepository<ParkingViewTable, Long> {
    ParkingViewTable findByPlateNumberAndCheckInTime(String plateNumber, LocalDateTime checkInTime);

    @Query("update ParkingViewTable t set t.totalPaid = t.totalPaid + :amountPaid, t.lastPayTime = :lastPayTime where t.id = :id")
    @Modifying
    void updatePaidAmountAndLastPaidTimeById(Long id, Integer amountPaid, LocalDateTime lastPayTime);
}
